package com.mty.mydemo.act;

import android.app.Activity;
import android.view.View;
import com.litesuits.common.utils.InputMethodUtils;
import com.litesuits.sdk.act.LiteFragment;
import com.mty.mydemo.View.CustomTipsView;
import com.qunduikj.sjb.sdk.model.enums.MobEvent;
import com.umeng.analytics.MobclickAgent;

/**
 * @author MaTianyu on 2015-05-07
 */
public abstract class BaseFragment extends LiteFragment implements SupportInterface {

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        ((BaseActivity) activity).setContainsFragment(true);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(TAG); //统计页面
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(TAG);
        InputMethodUtils.hideSoftInput(activity);
    }


    @Override
    public CustomTipsView createTipsView() {
        CustomTipsView tipsView = new CustomTipsView(activity);
        tipsView.setNoNetworkDetail(0, 0, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MobclickAgent.onEvent(activity, MobEvent.NetRetry.getEventID());//点击无网络重试
                loadDataStart();
            }
        });
        return tipsView;
    }



    public void setTitleBackground(int resID) {
        getDefaultTitleBar().getTvTitle().setBackgroundResource(resID);
    }

    public void setTitleText(int resID) {
        getDefaultTitleBar().getTvTitle().setText(resID);
    }




}
